//
//  ZSY_SearchTripTableViewCell.m
//  ZSY_BreadTrip
//
//  Created by 张诗宇 on 16/1/7.
//  Copyright © 2016年 张诗宇. All rights reserved.
//

#import "ZSY_SearchTripTableViewCell.h"

@interface ZSY_SearchTripTableViewCell ()

@property (nonatomic, retain) ZSY_BaseImageView *coverImageView;
@property (nonatomic, retain) ZSY_BaseLabel *wayLabel;
@property (nonatomic, retain) ZSY_BaseLabel *viewLabel;

@end

@implementation ZSY_SearchTripTableViewCell

- (void)dealloc {
    [_coverImageView release];
    [_wayLabel release];
    [_viewLabel release];
    [_trips release];
    [_nameLabel release];
    [super dealloc];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)setTrips:(ZSY_SearchTripModel *)trips {
    if (_trips != trips) {
        [_trips release];
        _trips = [trips retain];
        
        NSURL *url = [NSURL URLWithString:_trips.cover_image];
        [self.coverImageView sd_setImageWithURL:url];
        
        self.nameLabel.text = _trips.name;
        self.nameLabel.font = [UIFont systemFontOfSize:15];
        [self.nameLabel sizeToFit];
        
        self.wayLabel.text = [NSString stringWithFormat:@"%@ 足迹", _trips.waypoints];
        self.wayLabel.font = [UIFont systemFontOfSize:11];
        [self.wayLabel sizeToFit];
        
        self.viewLabel.text = [NSString stringWithFormat:@"%@ 浏览", _trips.view_count];
        self.viewLabel.font = [UIFont systemFontOfSize:11];
        [self.viewLabel sizeToFit];
        
        
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    
//    self.contentView.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:243 / 255.0 blue:233 / 255.0 alpha:1];
    
    self.coverImageView = [[ZSY_BaseImageView alloc] initWithFrame:CGRectMake(10, 5, WIDTH - 20, 100)];
    self.coverImageView.layer.cornerRadius = 4;
    self.coverImageView.layer.masksToBounds = YES;
    self.coverImageView.layer.borderWidth = 1;
    self.coverImageView.layer.borderColor = [UIColor lightGrayColor].CGColor;

    [self.contentView addSubview:_coverImageView];
    
    self.nameLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(10, 10, self.coverImageView.frame.size.width - 20, 20)];
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.coverImageView addSubview:_nameLabel];
    
    self.wayLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(10, 35, 100, 10)];
    self.wayLabel.textColor = [UIColor whiteColor];
    [self.coverImageView addSubview:_wayLabel];
    
    self.viewLabel = [[ZSY_BaseLabel alloc] initWithFrame:CGRectMake(10, 80, 100, 10)];
    self.viewLabel.textColor = [UIColor whiteColor];
    [self.coverImageView addSubview:_viewLabel];
    
    
}


@end
